<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let a={a:'a',b:'b',c:'c'};
       
        //自己实现迭代器接口
        a[Symbol.iterator]=function* (){
            console.log(this)
            for (const key in this) {
                if (this.hasOwnProperty.call(this, key)) {
                    const element = this[key];
                    yield element
                }
            }
           
        }
        
        for (const iterator of a) {
            console.log(iterator)
        }
    </script>
</body>
</html>